package com.thememaker.lockstyle;

import com.jfoenix.controls.JFXCheckBox;
import com.thememaker.lockstyle.bean.Lockscreen;
import com.thememaker.lockstyle.bean.Var;
import com.thememaker.lockstyle.bean.ui.*;
import com.thememaker.util.SVGLoadUtils;
import javafx.scene.Node;
import javafx.scene.control.TreeItem;

/**
 * Created by jiajun.jiang on 2018/4/27.
 */
public class LockCheckBoxTreeItem<T> extends TreeItem<String> {
    private T tag;
    private String mapName;
    private boolean selected;
    private JFXCheckBox jfxCheckBox = new JFXCheckBox();
    private BaseView leftIcon;

    public LockCheckBoxTreeItem() {
        jfxCheckBox.setCheckedColor(LockstyleMainController.buttonColor);
    }

    public T getTag() {
        return tag;
    }

    public void setTag(T tag) {
        this.tag = tag;
    }

    public String getMapName() {
        return mapName;
    }

    public void setMapName(String mapName) {
        this.mapName = mapName;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
        jfxCheckBox.setSelected(selected);
    }

    public BaseView getLeftIcon() {
        return leftIcon;
    }

    public void setLeftIcon(BaseView leftIcon) {
        this.leftIcon = leftIcon;
        Node node;
        if (leftIcon instanceof Group) {
            node = SVGLoadUtils.getInstance().getGroupXMLSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Image) {
            node = SVGLoadUtils.getInstance().getImageSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Button) {
            node = SVGLoadUtils.getInstance().getButtonXMLSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Text) {
            node = SVGLoadUtils.getInstance().getTextXMLSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Var) {
            node = SVGLoadUtils.getInstance().getVarXMLSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Lockscreen) {
            node = SVGLoadUtils.getInstance().getLockcreenXMLSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Slider) {
            node = SVGLoadUtils.getInstance().getUnlockerXMLSVG(15, LockstyleMainController.buttonColor);
        } else if (leftIcon instanceof Unlocker) {
            node = SVGLoadUtils.getInstance().getUnlockerXMLSVG(15, LockstyleMainController.buttonColor);
        } else {
            node = SVGLoadUtils.getInstance().getOtherXMLSVG(15, LockstyleMainController.buttonColor);
        }
        jfxCheckBox.setGraphic(node);
        this.setGraphic(jfxCheckBox);
    }

    public JFXCheckBox getJfxCheckBox() {
        return jfxCheckBox;
    }

    public void setJfxCheckBox(JFXCheckBox jfxCheckBox) {
        this.jfxCheckBox = jfxCheckBox;
    }
}
